/* 
 * frm-layout-3.0.js
 * @since 1.0 <2015-6-23> SoChishun Added.
 */

/**
 * 加载历史菜单
 * @since 1.0 <2015-6-8> SoChishun Added.
 */
function build_tab(tabs, menus) {
    var container = $('#nav_history');
    $(menus).each(function () {
        $(this.children).each(function () {
            $(this.children).each(function () {
                if ($.inArray(this.id, tabs.items)) {
                    $container.append('<li' + (tabs.current == this.id ? ' class="cur"' : '') + '><a href="' + this.url + '" data-id="' + this.id + '">' + this.name + '</a><i></i></li>');
                }
            })
        })
    })
}
/**
 * 动态生成导航菜单
 * @param object menus
 * @since 1.0 <2015-6-6> SoChishun Added.
 */
function build_menu(menus) {
    if (!menus) {
        alert('没有菜单数据!');
        return;
    }

    var submm = '';
    $(menus).each(function () {
        submm += '<div id="nav_sub_' + this.id + '" class="main-nav-sub">';
        $(this.children).each(function () {
            $(this.children).each(function () {
                submm += '<div><a href="/index.php/XCall_5_0' + this.url.substring(16) + '" data-id="' + this.id + '">' + this.name + '</a></div>';
            })
        })
        submm += '</div>';
    })
    $(submm).menu({onClick: function () {
            obj.config.menu_click_fn($(this).find('a'));
        }});
    $(menus).each(function () {
        $('#nav_' + this.id).menubutton({menu: '#nav_sub_' + this.id});
    })
}
